<template>
  <!--数字码使用验证-->
  <div class="shuzi">
    <p class="banner"><img src="../../../assets/banner.png" alt="" width="100%"></p>
    <wv-group>
      <wv-input label="数字码" placeholder="请输入相应服务的数字码" v-model="qrCode"></wv-input>
    </wv-group>
    <p class="link">
      <router-link to="/jilu" tag="span">使用验证记录</router-link>
      <router-link to="/useyanzheng" tag="span" class="saoyisao">扫一扫使用验证</router-link>
    </p>
    <div class="offer" @click="goCheck(qrCode)">使用验证</div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {checkAccountGoods} from '../../../../test/unit/http'
  import {Toast} from 'we-vue'
  export default {
    name: '',
    props: {},
    data() {
      return {
        qrCode: ''
      };
    },
    methods: {
      getData(params){
        checkAccountGoods(params).then(res => {
          if (res.code === 100) {
            console.log(res);
            let accountGoods = res.object;
            if (accountGoods.isVipCard == 1) {
              this.$router.push({name: 'yanzheng', query: {'accountGoodsId': accountGoods.accountGoodsId}})
            } else {
              this.$router.push({name: 'danci', query: {'accountGoodsId': accountGoods.accountGoodsId}})
            }
          } else {
            Toast.fail(res.info);
          }
        })
      },
      goCheck(qrCode){
        let params = {qrCode: qrCode};
        this.getData(params);
      }
    },
    created() {

    },
    components: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .weui-cell {
    background-color: #eee;
    height: 48px;
    line-height: 48px;
    border-radius: 5px;
    width: 80%;
    margin: auto;
  }

  .link {
    position: fixed;
    bottom: 90px;
    width: 100%;
    text-align: center;
    font-size: 13px;
    span:first-child {
      color: #999;
      margin-right: 20px;
    }
    .saoyisao {
      color: #f98e3c;
    }
  }

  .offer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: #f98e3c;
    height: 50px;
    line-height: 50px;
    color: #fff;
  }
</style>
